import React from 'react'

export default class ComponentDemo extends React.Component {
  constructor(props) {
    super(props)
    this.state = {
      data: {
        age: 18,
        name: '小毅'
      }
    }
  }

  changeAge = () => {
    const { data } = this.state
    data.age++
    this.setState({
      data
    })
  }

  render() {
    const { data } = this.state
    return (
      <div>
        <h2>1、COmponent </h2>
        <h4>name:{data.name}</h4>
        <h4>age:{data.age}</h4>
        <button onClick={this.changeAge}>age ++</button>
      </div>
    )
  }
}
